
#if !SILVERLIGHT
using QdbUnit;
using QdbUnit.Extensions;
using Qdb;
using Qdb.Config;
using Qdb.Ext;
using Qdb.Query;

namespace Qdb.Tests.Common.Concurrency
{
	public class InternStringsTestCase : QdbClientServerTestCase
	{
		public static void Main(string[] args)
		{
			new Qdb.Tests.Common.Concurrency.InternStringsTestCase().RunConcurrency
				();
		}

		public string _name;

		public InternStringsTestCase() : this(null)
		{
		}

		public InternStringsTestCase(string name)
		{
			_name = name;
		}

		protected override void Configure(IConfiguration config)
		{
			config.InternStrings(true);
		}

		protected override void Store()
		{
			string name = "Foo";
			Store(new Qdb.Tests.Common.Concurrency.InternStringsTestCase(name));
			Store(new Qdb.Tests.Common.Concurrency.InternStringsTestCase(name));
		}

		public virtual void Conc(IExtObjectContainer oc)
		{
			IQuery query = oc.Query();
			query.Constrain(typeof(Qdb.Tests.Common.Concurrency.InternStringsTestCase
				));
			IObjectSet result = query.Execute();
			Assert.AreEqual(2, result.Count);
			Qdb.Tests.Common.Concurrency.InternStringsTestCase first = (Qdb.Tests.Common.Concurrency.InternStringsTestCase
				)result.Next();
			Qdb.Tests.Common.Concurrency.InternStringsTestCase second = (Qdb.Tests.Common.Concurrency.InternStringsTestCase
				)result.Next();
			Assert.AreSame(first._name, second._name);
		}
	}
}
#endif // !SILVERLIGHT
